package org.meichao.hello.service;

import com.alibaba.fastjson.JSONObject;
import org.meichao.config.annotation.Read;
import org.meichao.hello.dao.HelloMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HelloService {

    @Autowired
    private HelloMapper helloMapper;

    /**
     * @Read 表明这个方法里使用的是读库
     * @Transational 表明这个方法使用的事务传播时什么
     *  Propagation.NOT_SUPPORTED表明无事务
     * @return
     */
    @Read
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<JSONObject> getUser(){
        return helloMapper.getUser();
    }

}
